package com.guangdujs.kis.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.guangdujs.common.annotation.Log;
import com.guangdujs.common.core.controller.BaseController;
import com.guangdujs.common.core.domain.AjaxResult;
import com.guangdujs.common.enums.BusinessType;
import com.guangdujs.kis.domain.TOrganization;
import com.guangdujs.kis.service.ITOrganizationService;
import com.guangdujs.common.utils.poi.ExcelUtil;
import com.guangdujs.common.core.page.TableDataInfo;

/**
 * 客户Controller
 * 
 * @author kis
 * @date 2022-11-01
 */
@RestController
@RequestMapping("/kis/Organization")
public class TOrganizationController extends BaseController
{
    @Autowired
    private ITOrganizationService tOrganizationService;

    /**
     * 查询客户列表
     */
    @PreAuthorize("@ss.hasPermi('kis:Organization:list')")
    @GetMapping("/list")
    public TableDataInfo list(TOrganization tOrganization)
    {
        startPage();
        List<TOrganization> list = tOrganizationService.selectTOrganizationList(tOrganization);
        return getDataTable(list);
    }

    /**
     * 导出客户列表
     */
    @PreAuthorize("@ss.hasPermi('kis:Organization:export')")
    @Log(title = "客户", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TOrganization tOrganization)
    {
        List<TOrganization> list = tOrganizationService.selectTOrganizationList(tOrganization);
        ExcelUtil<TOrganization> util = new ExcelUtil<TOrganization>(TOrganization.class);
        util.exportExcel(response, list, "客户数据");
    }

    /**
     * 获取客户详细信息
     */
    @PreAuthorize("@ss.hasPermi('kis:Organization:query')")
    @GetMapping(value = "/{fitemid}")
    public AjaxResult getInfo(@PathVariable("fitemid") Long fitemid)
    {
        return AjaxResult.success(tOrganizationService.selectTOrganizationByFitemid(fitemid));
    }

}
